import {INCREMENT,DECREMENT} from './const.js'

let initState = 0;

function Reducer(preState = initState, action) {
    const { type, data } = action;
    let result = 0;
    switch (type) {
        case INCREMENT:
            result = preState + data*1;
            break;
        case DECREMENT:
            result = preState - data*1;
            break;
        default:
            result = preState;
            break;
    }
    return result
}

export default Reducer